package view.admin;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JPanel;
import controller.KeyHandler;
import controller.ActionEvents.ActionHandler;

import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JCheckBox;

import view.MainFrame;
import javax.swing.ImageIcon;


public class AdminCreateUser extends JPanel {
	

	private JLabel lblCreateUser;
	private JTextField textfieldNewUser;
	private JTextField textfieldNewUserPassword;
	private JButton btnAddNewUser;
	private JCheckBox chckbxAdmin;
	private JTextField txtName;
	private MainFrame frame;
	private ActionHandler actionHandler;
	private JButton btnMainMenu;
	private JLabel lblSetPasswordStrength;
	private JLabel lblPasswordStrength;
	private KeyHandler keyHandler;
	
	public AdminCreateUser(ActionHandler actionHandler, KeyHandler keyHandler)
	{
		setPreferredSize(new Dimension(750, 480));
		setLayout(null);
		this.actionHandler = actionHandler;
		this.keyHandler = keyHandler;
		setBackground(Color.WHITE);
		
		
		
		lblCreateUser = new JLabel("Create user");
		lblCreateUser.setFont(new Font("Lucida Grande", Font.PLAIN, 28));
		lblCreateUser.setBounds(327, 24, 182, 36);
		add(lblCreateUser);
		
		textfieldNewUser = new JTextField();
		textfieldNewUser.setText("ID");
		textfieldNewUser.setBounds(310, 136, 206, 36);
		textfieldNewUser.setBackground(Color.decode("#f1f1f1"));
		add(textfieldNewUser);
		textfieldNewUser.setColumns(10);
		
		textfieldNewUserPassword = new JTextField();
		textfieldNewUserPassword.setText("Password");
		textfieldNewUserPassword.setColumns(10);
		textfieldNewUserPassword.setBounds(310, 184, 206, 36);
		textfieldNewUserPassword.setBackground(Color.decode("#f1f1f1"));
		textfieldNewUserPassword.addKeyListener(keyHandler);
		add(textfieldNewUserPassword);
		
		btnAddNewUser = new JButton("");
		btnAddNewUser.setIcon(new ImageIcon(AdminCreateUser.class.getResource("/Pictures/green/submit.png")));
		btnAddNewUser.setBounds(349, 326, 134,39);
		btnAddNewUser.addActionListener(actionHandler);
		btnAddNewUser.setBorderPainted(false);
		btnAddNewUser.setContentAreaFilled(false);
		btnAddNewUser.setActionCommand("AddNewUser");
		add(btnAddNewUser);
		
		chckbxAdmin = new JCheckBox("Create admin user");
		chckbxAdmin.setBounds(310, 278, 176, 29);
		chckbxAdmin.setIcon(new ImageIcon(AdminCreateUser.class.getResource("/Pictures/ux/checkBox.png")));
		add(chckbxAdmin);
		
		txtName = new JTextField();
		txtName.setText("Full Name");
		txtName.setColumns(10);
		txtName.setBounds(310, 243, 206, 36);
		txtName.setBackground(Color.decode("#f1f1f1"));
		add(txtName);
		
		lblSetPasswordStrength = new JLabel("");
		lblSetPasswordStrength.setBounds(432, 215, 99, 16);
		add(lblSetPasswordStrength);
		
		lblPasswordStrength = new JLabel("Password Strength: ");
		lblPasswordStrength.setBounds(310, 215, 130, 16);
		add(lblPasswordStrength);
		
		btnMainMenu = new JButton("Main menu");
		btnMainMenu.setBounds(587, 445, 117, 29);
		btnMainMenu.addActionListener(actionHandler);
		btnMainMenu.setBorderPainted(false);
		btnMainMenu.setContentAreaFilled(false);
		btnMainMenu.setActionCommand("backToAdminMenu");
		add(btnMainMenu);
	}

	/**
	 * @return the textfieldNewUser
	 */
	public JTextField getTextfieldNewUser() {
		return textfieldNewUser;
	}

	/**
	 * @return the textfieldNewUserPassword
	 */
	public JTextField getTextfieldNewUserPassword() {
		return textfieldNewUserPassword;
	}

	/**
	 * @return the chckbxAdmin
	 */
	public JCheckBox getChckbxAdmin() {
		return chckbxAdmin;
	}

	/**
	 * @return the textFieldName
	 */
	public JTextField getTxtName() {
		return txtName;
	}

	/**
	 * @param textfieldNewUser the textfieldNewUser to set
	 */
	public void setTextfieldNewUser(JTextField textfieldNewUser) {
		this.textfieldNewUser = textfieldNewUser;
	}

	/**
	 * @param textfieldNewUserPassword the textfieldNewUserPassword to set
	 */
	public void setTextfieldNewUserPassword(JTextField textfieldNewUserPassword) {
		this.textfieldNewUserPassword = textfieldNewUserPassword;
	}

	/**
	 * @param chckbxAdmin the chckbxAdmin to set
	 */
	public void setChckbxAdmin(JCheckBox chckbxAdmin) {
		this.chckbxAdmin = chckbxAdmin;
	}

	/**
	 * @param txtName the txtName to set
	 */
	public void setTxtName(JTextField txtName) {
		this.txtName = txtName;
	}

	/**
	 * @return the lblPasswordStrength
	 */
	public JLabel getLblSetPasswordStrength() {
		return lblSetPasswordStrength;
	}

	/**
	 * @param lblSetPasswordStrength the lblPasswordStrength to set
	 */
	public void setLblSetPasswordStrength(JLabel lblSetPasswordStrength) {
		this.lblSetPasswordStrength = lblSetPasswordStrength;
	}

	/**
	 * @return the btnAddNewUser
	 */
	public JButton getBtnAddNewUser() {
		return btnAddNewUser;
	}

	/**
	 * @return the btnMainMenu
	 */
	public JButton getBtnMainMenu() {
		return btnMainMenu;
	}
}
